import axios from "axios"



export default {
    //获取自提点的数据
    get: ({ curPage, eachPage }) => axios.get('/api/address', { params: { curPage, eachPage } }).then(res => res.data),
    //新增自提点
    addAddress: (name, Address, longitude, latitude, Cold_store, Phone, Open_hours) => {
        return axios.post('/api/address/add-address', {
            name: name,
            Address: Address,
            longitude: ~~longitude,
            latitude: ~~latitude,
            Cold_store: Cold_store,
            Phone: ~~Phone,
            Open_hours: Open_hours
        }
        ).then(res => res.data)
    },
    // 删除自提点
    deleteAddress: (_id) =>
        axios({
            method: "delete",
            url: "/api/address/delet-address",
            data: {
                _id
            }
        }).then(data => data),

    //修改
    amendAddress: (newAddress) => axios.put('/api/address/amend-address', newAddress).then(res => res.data),

    // 删除图片
    deleteImag: async ({
        _id,
        Image,
        token
    }) => axios({
        method: "delete",
        url: "/res/address/delImg",
        data: {
            _id,
            Image,
            token,
        }
    }).then(data => data),

    onSearch: value => {
        console.log(value);
        return axios.get('/api/address/search', { params: { value } }).then(res=>res.data)
    }


}